package com.nsqt.common.utils;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ParseJson {
    public static String parseObject(HttpServletRequest request) {
        String params = new String();
        try {
            BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
            StringBuilder requestStrBuilder = new StringBuilder();
            String inputStr;
            while ((inputStr = streamReader.readLine()) != null)
                requestStrBuilder.append(inputStr);
            JSONObject jsonObject = JSONObject.parseObject(requestStrBuilder.toString());
            params = jsonObject.toJSONString();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return params;
    }
}
